{{Operating System Research Build Receiver}}  

CON
  _clkmode = xtal1 + pll16x                                               
  _xinfreq = 5_000_000

OBJ
  xbee      : "XBee_Object.spin"
  pst       : "Parallax Serial Terminal"
  functions : "Functions.spin"
  
VAR
  long stack[10]

  byte Forward
  byte Reverse
  byte Left
  byte Right
  byte Stop
  
PUB Main  
  pst.start(115200)
  waitcnt(clkfreq + cnt)
  functions.initialize
  pst.str(String("Starting to receive packets from transmitter.",13))
  xbee.start(4,3,0,9600)
  
  pst.str(String("Received the following: ",13))

  repeat
    Parse
    
PRI Parse  
  pst.dec(xbee.rx)
  pst.str(String(13))
  CASE xbee.rx                                                  'Note: Case structures can only have four options
    1: driveHandler(4, Stop)
    2: driveHandler(4, Reverse)
    3: driveHandler(4, Forward)
    4,5:
      if (xbee.rx == 4)
        driveHandler(4, Right)
      if (xbee.rx == 5)
        driveHandler(4, Left)
    OTHER: pst.str(String("What is this?",13))

PUB driveHandler(Number, Movement)
  cogstop(Number)
  coginit(Number, functions.Drive(Movement), @stack)            'Does this actually work; based off of old code
  return                                                        'Is this needed to stop the process?

{{
QUESTIONS:
If I place this in the functions file, do I have to say "functions.Drive()" or just "Drive()"?
Do need to add a return to the driveHandler()?
Will this actually work? It is somewhat based off of the old code.
Do you see any areas for improvement?

NOTE TO SELF:
Change the prefix functions to funct. (A Global Proposed Change)
}}